#ifndef _PREFIX_TREE_HPP__ 
#define _PREFIX_TREE_HPP__ 1
#define ENGLISH_ALPHABET_SIZE 26
#define RUSSIAN_ALPHABET_SIZE 33
#include <Types.h>
#include <STLVector.hpp>
#include <STLString.hpp>
#include <map>
#define MAX_WORD_LENGTH 256
using namespace STLW;
class PrefixTreeNode{
public:
	UINT_32 id_node;
	UINT_32 IDF;
//	map<UINT_16, UINT_16> data;
	UINT_32 data[ENGLISH_ALPHABET_SIZE + RUSSIAN_ALPHABET_SIZE + 10];

public:
	//Constructor
	PrefixTreeNode(UINT_32 node_id);

	// bit logic with 
	INT_32 GetNextNodeId(CCHAR_8 next_symbol);

	// bit logic with add element
	void PutNextNodeIdForSymbol(UINT_32 next_node_id, CCHAR_8 symbol);


	// Destructor
	virtual ~PrefixTreeNode() throw ();
	
};

class PrefixTree {
public:
	UINT_32 size;
	vector<PrefixTreeNode*> nodes;
//	PrefixTreeNode nodes[MAX_SIZE_OF_TREE];
public:
	// Constructor
	PrefixTree();


	//add word to prefix tree
	void AddWord(CCHAR_P word, UINT_32 IDF);

	//get 5 hints for word
	void GetHintsForWord(CCHAR_P word);

	// Dump tree to file
	UINT_32 Dump(CCHAR_P filename);

	// Resotre tree from the file
	UINT_32 Restore(CCHAR_P filename); 


	void RecursiveTour(UINT_32 id_node, string first_part_of_word);

	// desrtuctor
	virtual ~PrefixTree() throw ();
};

#endif
